<template>
 <div>
     <el-tree :data="categorys" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
 </div>
</template>

<script>
 export default {
   name: '',
   props: {
   },
   components: {

   },
   data () {
     return {
        defaultProps: {
          children: 'children',
          label: 'name'
        }
     }
   },
   methods: {
        handleNodeClick(data,node) {
            if(node.childNodes.length == 0){
              this.$emit("categoryData",data,node)
            }

        },

   },
   mounted() {

   },
   created(){
    //调用仓库actions发送请求获取分类数据
    this.$store.dispatch("mystore/getCategorys");
   },
   watch: {

   },
   computed: {
     categorys(){
       return this.$store.state.mystore.categorys;
     }
   },
   filters: {

   }
 }
</script>

<style scoped lang='scss'>

</style>